using System;
using System.Collections.Generic;
using System.Text;

namespace Athena.Core
{
    [Serializable()]
    public class Terminator : Part
    {
        public override void GenerateDrawable(System.Drawing.PointF point)
        {
            Drawable = new Objects.TerminatorGlyph(point);
            ((Objects.PartGlyph)_Drawable).GenerateModifiers();            
        }

        public Terminator()
            : base("terminator", Part.COUNT.ToString(), "AAAAAAAA")
        {
            _AllowPoPSFlow = false;
            _PoPS_Right = new PoPSRate(this, "0");
        }

        public Terminator(string id, string sequence)
            : base("terminator", id, sequence)
        {
            InputConnectionsAllowed = false;
            OutputConnectionsAllowed = false;
            _AllowPoPSFlow = false;
            _PoPS_Right = new PoPSRate(this, "0");
        }

        public override Orientation Direction
        {
            get
            {
                return base.Direction;
            }
            set
            {
                if (_Direction != value)
                {
                    base.Direction = value;

                    Edge.AUTO_MODIFIERS = false;
                    if (value == Orientation.forward)
                    {
                        _PoPS_Right = new PoPSRate(this, "0");
                        if (_PoPS_Left != null)
                            _PoPS_Right.CopyModifiers(_PoPS_Left);
                        if (_Right != null)
                            PoPS_Left = _Right.PoPS_Left;
                        else
                            PoPS_Left = new PoPSRate(this);
                        //PoPS_Right = new PoPSRate(this);
                        PoPS_Right = _PoPS_Right;
                        _PoPS_Right.ParentPart = this;
                    }
                    else
                    {
                        _PoPS_Left = new PoPSRate(this, "0");
                        if (_PoPS_Right != null)
                            _PoPS_Left.CopyModifiers(_PoPS_Right);
                        if (_Left != null)
                            PoPS_Right = _Left.PoPS_Right;
                        else
                            PoPS_Right = new PoPSRate(this);
                        //PoPS_Left = new PoPSRate(this);
                        PoPS_Left = _PoPS_Left;
                        _PoPS_Left.ParentPart = this;
                    }
                    Edge.AUTO_MODIFIERS = true;
                }
            }
        }
    }
}
